home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / SPEC Libs / TimingOperations.lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  24.9 KB  |  677 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:    TimingOperations.lib
  5. #
  6. #    Contains:    Higher level timing routines
  7. #
  8. #    Written by:    KTA
  9. #
  10. #    Copyright:    © 1993-1996 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #        <13>      5/1/96    MDF        Removed call to SwitchScriptBackToOrig() in TimeSaveAs() and
  19. #                                    TimeOpenFile(), per Intl request.
  20. #        <12>     2/28/95    ML        marked
  21. #        <11>     2/14/95    KTA        SetUpDocumentWindow() - Added BooleanFlag to FindWindow() call
  22. #        <10>     1/31/95    ML        add IvyOperations.Lib to declaration, change all ivy calls to
  23. #                                    _Ivy calls
  24. #         <9>     1/19/95    KTA        Changed the name of ExceptionHandler() to ExceptionDispatcher().
  25. #         <8>     12/6/94    ML        Added Exception Handling support
  26. #         <7>     6/28/94    ML        PerformScroll() - return returnval# ML    6/28/94 call
  27. #                                    PerformScroll() multiple times and increment pWaitForScroll
  28. #                                    #                if it isn't long enough
  29. #         <6>      6/2/94    ML        Enhanced TimeScrolling() and PerformScrolling() for Thumbnail
  30. #                                    method and ScrollByScreen option.
  31. #         <5>     4/27/94    KTA        TimeFontTesting() - Added patience.
  32. #         <4>     4/19/94    ML        Make libraries declaration one line, move SaveAsPerformance,
  33. #                                    OpenFilePerformance, and SF_Stoptimer to TimingSFDialog.Lib
  34. #         <3>     4/18/94    ML        Revved libraries declaration to "Ivy.vulib" from Ivy.1.1.vulib",
  35. #                                    revised globals declaration in StopTimerIV(), removed
  36. #                                    gOpenFileHook1 assigment in TimeOpenFile() and gSaveAsHook1,
  37. #                                    gSaveAsHook3 assignments in TimeSaveAs().
  38. #         <2>     4/15/94    KTA        Added check to insure that IV initialized correctly.
  39. #         <1>     4/12/94    ML        Moved into Libraries project from Timing project
  40. #     <1.0.5>     4/12/94    ML        Added OpenFilePerformance(), SaveAsPerformance(),
  41. #                                    SF_StopTImer(). Replace stoptimer() w/stoptimerVU(), remove
  42. #                                    gTiming, removed TimeOpenFileVU, TimeSaveAsVU.  TimeCutPaste()
  43. #                                    -add IVInit and IVQuit.  TimeSaveAs - add IVInit and IVQuit.
  44. #                                    TimeOpenFile - add IVInit and IVQuit.
  45. #                                    
  46. #                                    
  47. #     <1.0.4>     12/1/93    KTA        TimeSaveAs() and TImeOpenFile() now call a new task,
  48. #                                    GetFirstTwoMenusRect(), to determine when they are completed.
  49. #     <1.0.3>    11/22/93    KTA        SetUpDocumentWindow() now calls findWindow so we can pass a
  50. #                                    variety of specifiers
  51. #        <1>         11/16/93    KTA        Created
  52. #
  53. # ****************************************************************************
  54. #
  55.  
  56.  
  57. ########################################################################
  58. #                            External libraries 
  59. #=======================================================================
  60. Libraries "UserInterface.lib", "Font.Lib", "Ivy.vulib", "TimingBasics.Lib",
  61. "StandardFile.Lib", "WorldReady.Lib", "Output.Lib", "ExceptionHandling.Lib",
  62. "IvyOperations.Lib";
  63.  
  64. #########################################################################
  65. #                         GetProcessListIconRect()
  66. #=======================================================================
  67. # Author:              KTA
  68. # Description:        Returns the rect of the application icon for the process list menu.
  69. # Parameters:        none
  70. # Returns:            Returns the rect of the application icon for the process list menu.
  71. # Example:            GetProcessListIconRect();
  72. # Assumptions        Processlist is the farthest menu to the right.
  73. #=======================================================================
  74. # History:
  75. # ML    11/29/94    Added Exception Handling support
  76. #########################################################################
  77. TASK GetProcessListIconRect()
  78. begin
  79.     try match[screen m:true r:?ScreenRect];
  80.     catch theError
  81.         ExceptionDispatcher(theError);
  82.     LeftPoint := ScreenRect[3]-34;
  83.     theAppIconRect := {LeftPoint,0,LeftPoint+16,ScreenRect[2]+18};
  84.     Return(theAppIconRect);
  85. end;
  86. #########################################################################
  87. #                         GetAppleMenuIconRect()
  88. #=======================================================================
  89. # Author:              KTA
  90. # Description:        Returns the rect of the Apple icon for the Apple menu.
  91. # Parameters:        none
  92. # Returns:            Returns the rect of the Apple icon for the Apple menu.
  93. # Example:            GetAppleMenuIconRect();
  94. # Assumptions        Apple menu is the farthest menu to the left.
  95. #=======================================================================
  96. # History:
  97. # ML    11/29/94    Added Exception Handling support
  98. #########################################################################
  99. TASK GetAppleMenuIconRect()
  100. begin
  101.     try match[screen m:true r:?ScreenRect];
  102.     catch theError
  103.         ExceptionDispatcher(theError);
  104.     LeftPoint := ScreenRect[1]+16;
  105.     theAppIconRect := {LeftPoint,0,LeftPoint+16,ScreenRect[2]+18};
  106.     Return(theAppIconRect);
  107. end;
  108. #########################################################################
  109. #                         GetFirstTwoMenusRect()
  110. #=======================================================================
  111. # Author:              KTA
  112. # Description:        Returns the rect of the Apple menu and the file menu
  113. # Parameters:        none
  114. # Returns:            Returns the rect of the Apple menu and the file menu.
  115. # Example:            GetFirstTwoMenusRect();
  116. # Assumptions        .
  117. #=======================================================================
  118. # History:
  119. # ML    11/29/94    Added Exception Handling support
  120. #########################################################################
  121. TASK GetFirstTwoMenusRect()
  122. begin
  123.     try match[screen m:true r:?ScreenRect];
  124.     catch theError
  125.         ExceptionDispatcher(theError);
  126.     LeftPoint := ScreenRect[1]+16;
  127.     theMenusRect := {LeftPoint,0,LeftPoint+60,ScreenRect[2]+18};
  128.     Return(theMenusRect);
  129. end;
  130.  
  131. #########################################################################
  132. #                         TimeCutPaste()
  133. #=======================================================================
  134. # Author:              KTA
  135. # Description:        Will cut and paste the entire contents of a document and time how long
  136. #                    the operations take.
  137. # Parameters:        pNumTimes - number of times to time the operation.
  138. # Returns:            nothing
  139. # Example:            TimeCutPaste();
  140. # Assumptions :     Requires 'STOP' tag at bottom of document in Geneva, 12 point, plain
  141. #                    Also requires :
  142. #                        keyEq('a') will select all
  143. #                        keyEq('x') will cut
  144. #                        keyEq('v') will paste
  145. #                        and that pasting will display the end of the document 
  146. #                        (where 'Stop' should exist).
  147. #=======================================================================
  148. # History:
  149. # ML    3/31/94    Add IVInit and IVQuit
  150. # KTA    4/15/94    Added check to insure that IV initialized correctly
  151. # ML    11/29/94    Added Exception Handling support
  152. # ML    1/31/95    Use _Ivy calls
  153. #########################################################################
  154. TASK TimeCutPaste(pNumTimes := 1)
  155. begin
  156.     if (InitIvy())
  157.     begin
  158.         KeyEq('a');    # Select All
  159.         KeyEq('x');    # Cut
  160.             wait(2);
  161.             if(DialogCheck('',1))    # probably out of memory
  162.             begin
  163.                 Println "NOTE:!@#$% Cannot complete timing of CUT and Paste";
  164.                 return(0);
  165.             end;
  166.         KeyEq('v');    # Paste
  167.         LogStr("##### We've reset the Document");
  168.         
  169.         try match[window o:1 r:?theRect];
  170.         catch theError
  171.             ExceptionDispatcher(theError);
  172.         waitingRect := LocateTheString(theRect);
  173.         #println "This is the WaitingRect - ", waitingRect;
  174.         _Ivy(task IVCreateImageFile, {"Stop", waitingRect});
  175.         
  176.         KeyEq('a');    # Select All
  177.         KeyEq('x');    # Cut
  178.         _Ivy(task IVCreateImageFile, {"NoStop", waitingRect});
  179.         KeyEq('v');    # Paste
  180.         
  181.         LogStr("###### Doing the Timing Thing");
  182.         InstallIVTimingMethod();
  183.         for i := 1 to pNumTimes
  184.         begin
  185.             global gImageFile:= "NoStop";
  186.             global gRect := waitingRect;
  187.             KeyEq('a');    # Select All
  188.             global gTimedEvent := {1,"Cut contents of document"};    
  189.             KeyEq('x');    # Cut
  190.             StopTimerIV();
  191.             global gImageFile:= "Stop";
  192.             global gRect := waitingRect;
  193.             global gTimedEvent := {2,"Paste contents of document"};    
  194.             KeyEq('v');
  195.             StopTimerIV();
  196.         end;
  197.         _Ivy(task IVDeleteImageFile, {"Stop"});
  198.         _Ivy(task IVDeleteImageFile, {"NoStop"});
  199.         RemoveIVTimingMethod();
  200.         QuitIvy();
  201.     end;
  202.     else
  203.     begin
  204.         println "Problem initializing IV";
  205.         exit;
  206.     end;
  207. end;    
  208.  
  209. #########################################################################
  210. #                         TimeSaveAs(pFileName, pSaveMI)
  211. #=======================================================================
  212. # Author:              KTA
  213. # Description:        Sets up the requirements for timing utilizing IVY and times
  214. #                    how long it takes an application to save a file. Then removes
  215. #                    the all global varibles that are defined in order to do timing.
  216. # Parameters:        pFileName - FileName for the document you want to save.
  217. #                    pSaveMI - 'Save As…' menuitem descriptor (ordinality contained in a list)
  218. # Returns:            Nothing
  219. # Example:            TimeSaveAs('@TestDoc', {7,2});
  220. # Assumptions        Processlist is the farthest menu to the right.
  221. #=======================================================================
  222. # History:
  223. # ML    3/31/94    Add IVInit and IVQuit
  224. # KTA    4/15/94    Added check to insure that IV initialized correctly
  225. # ML    4/18/94    removed gSaveAsHook1, gSaveAsHook3 definitions
  226. # ML    1/31/95    Use _Ivy calls
  227. # MDF    04/30/96    Removed SwitchScriptBackToOrig() as it will be done
  228. #                    by gSaveAsHook3, per Intl request.
  229. #########################################################################
  230. TASK TimeSaveAs(pFileName := '',pSaveMI := {8,2})
  231. begin
  232.     if(InitIvy())
  233.     begin
  234.  
  235.         ### Hooks to time StandardFile
  236.         global gSaveAsHook2 := task StopTimerIV;
  237.     
  238.         #### SaveAs
  239.         theRect := GetFirstTwoMenusRect();
  240.         _Ivy(task IVCreateImageFile, {"testImage", theRect});
  241.         global gImageFile:= "testImage";
  242.         global gRect := theRect;
  243.         global gTimedEvent := {3,"Saving File", "{pFileName}"};    
  244.         InstallIVTimingMethod();
  245.         SwitchScriptToUS();                        # All standardFile operations are going to happen in english
  246.     
  247.         SaveAs(pFileName,,pSaveMI);
  248.         
  249.         RemoveIVTimingMethod();
  250.         
  251.         _Ivy(task IVDeleteImageFile, {"testImage"});
  252.         QuitIvy();
  253.         
  254.         ### Remove hooks to time StandardFile
  255.         global gSaveAsHook2 := 0;
  256.     end;
  257.     else
  258.     begin
  259.         println "Problem initializing IV";
  260.         exit;
  261.     end;
  262. end;
  263.     
  264. #########################################################################
  265. #                         TimeOpenFile(pFileName, pOpenMI)
  266. #=======================================================================
  267. # Author:              KTA
  268. # Description:        Sets up the requirements for timing utilizing IVY and times
  269. #                    how long it takes an application to open a file. Then removes
  270. #                    the all global varibles that are defined in order to do timing.
  271. # Parameters:        pFileName - FileName for the document you want to save.
  272. #                    pOpenMI - 'Open' menuitem descriptor (ordinality contained in a list)
  273. # Returns:            Nothing
  274. # Example:            TimeOpenFile('@TestDoc', {2,2});
  275. # Assumptions        Processlist is the farthest menu to the right.
  276. #=======================================================================
  277. # History:
  278. # ML    3/31/94    Add IVInit and IVQuit
  279. # KTA    4/15/94    Added check to insure that IV initialized correctly
  280. # ML    4/18/94    removed global gOpenFileHook1 definitions
  281. # ML    1/31/95    Use _Ivy calls
  282. # MDF    04/30/96    Removed SwitchScriptBackToOrig() since script should always
  283. #                    be "U.S.", per Intl request.
  284. #########################################################################
  285. TASK TimeOpenFile(pFileName := '', pOpenMI := {2,2})
  286. begin
  287.     if (InitIvy())
  288.     begin
  289.         ### Hooks to time StandardFile
  290.         global gOpenFileHook2 := task StopTimerIV;
  291.         
  292.         ### OpenFile
  293.         theRect := GetFirstTwoMenusRect();
  294.         _Ivy(task IVCreateImageFile, {"testImage", theRect});
  295.         global gImageFile:= "testImage";
  296.         global gRect := theRect;
  297.         global gTimedEvent := {4,"Opening File","{pFileName}"};    
  298.         
  299.         SwitchScriptToUS();                        # All standardFile operations are going to happen in english
  300.         InstallIVTimingMethod();
  301.         
  302.         openFile(pFileName, pOpenMI);
  303.         
  304.         RemoveIVTimingMethod();
  305.     
  306.         _Ivy(task IVDeleteImageFile, {"testImage"});
  307.         QuitIvy();
  308.     
  309.         ### Remove Hooks to time StandardFile
  310.         global gOpenFileHook2 := 0;
  311.     end;
  312.     else
  313.     begin
  314.         println "Problem initializing IV";
  315.         exit;
  316.     end;
  317. end;
  318.  
  319. #########################################################################
  320. #                    TimeFontTesting(numTimes, pFontRecord)    
  321. #========================================================================
  322. # Author:        KTA
  323. # Description:    Times the selection of Fonts, Sizes and Styles.  Normally this 
  324. #                task will be called after all text has been selected.
  325. # Parameters:    numTimes - number of times to perform the timed tests.
  326. #                pFontRecord - (optional) makes it possible to pass in a 
  327. #                            fontRecord to define which fonts, sizes and styles 
  328. #                            will be selected and therefore timed.  FontRecords 
  329. #                            take the following form: 
  330. #                            {'FontName', 'SizeName',{'StyleName1', 'StyleName2', etc}}
  331. # Returns:        nothing
  332. # Example:        TimeFontTesting(4, {'Times', '12',{'Bold', 'Italics'}});
  333. #                 TimeFontTesting(2, );
  334. # Assuptions: a                 
  335. #========================================================================
  336. # History:
  337. #    KTA        11/1/93        Created
  338. #    ML        3/31/94        revised gTimedEvent for TCS info, removed gTiming
  339. #    KTA        4/27/94        Added patience
  340. #########################################################################
  341. TASK TimeFontTesting(numTimes := 1, pFontRecord := {})
  342. begin
  343.     global gCurrFontMenu, gFontList, gFontStyleList, gFontSizeList, gTimedEvent;
  344.     Println "The gFontList := ", gFontList;
  345.     Println "The gFontSizeList := ", gFontSizeList;
  346.     Println "The gFontStyleList := ", gFontStyleList;
  347.     InstallVUTimingMethod();    
  348.     tempPatience := patience(3);
  349.     
  350.     for i := 1 to numTimes
  351.     begin
  352.         if (pFontRecord)
  353.             theFontRecord := pFontRecord;
  354.         else
  355.             theFontRecord := RandomFontRecords();
  356.             
  357.         println "Current FontRecord - ", theFontRecord;
  358.         ## Start with fonts
  359.         if not(global gCurrFontMenu)                # Menu(s) which contain the menu item
  360.         begin
  361.             gCurrFontMenu := FindMenu(global gFontList[1]);    
  362.             if not(gCurrFontMenu)                # Menu(s) which contain the menu item
  363.                 gCurrFontMenu := FindMenu("Chicago");    
  364.         end;
  365.         currFontName := theFontRecord[1];
  366.         gTimedEvent := {5,"Select Font","{currFontName}"};
  367.         SelectmenuItem(theFontRecord[1], gCurrFontMenu[1], gCurrFontMenu[2]);
  368.         StopTimerVU();
  369.             
  370.         ## Sizes
  371.         if not(global gCurrSizeMenu)                # Menu(s) which contain the menu item
  372.             gCurrSizeMenu := FindMenu(global gFontSizeList[1]);    
  373.         
  374.         currSize := theFontRecord[2];
  375.         gTimedEvent := {6,"Select Size", "{currSize}"};
  376.         SelectmenuItem(theFontRecord[2], gCurrSizeMenu[1], gCurrSizeMenu[2]);
  377.         StopTimerVU();
  378.         
  379.         ## Styles
  380.         if not(global gCurrStyleMenu)                # Menu(s) which contain the menu item
  381.         begin
  382.             if (global gFontStyleList[1])
  383.                 gCurrStyleMenu := FindMenu(global gFontStyleList[1]);    
  384.             if not(gCurrStyleMenu)                # Help insure that it is initilized correctly
  385.                 gCurrStyleMenu := FindMenu('Bold');
  386.         end;
  387.         
  388.         for each currentStyle in theFontRecord[3]             # For all the Styles
  389.         begin
  390.             gTimedEvent := {7,"Selecting a Style","{currentStyle}"};
  391.             SelectmenuItem(currentStyle, gCurrStyleMenu[1], gCurrStyleMenu[2]);
  392.             StopTimerVU();
  393.         end;
  394.     end;
  395.     patience(tempPatience);
  396.     RemoveVUTimingMethod();
  397. end;
  398.  
  399. #########################################################################
  400. #                     SetUpDocumentWindow()
  401. #========================================================================
  402. # Author:        MDS
  403. # Description:    Positions the title bar of a document at location {0,20}
  404. #                and resizes the document to aconstant size.
  405. #                (according to the main screen size)            
  406. # Assumtions:    the document window is the top window (ordinality: 1)
  407. # Parameters:    pWindowTitle - Title of the docuemnt to resize
  408. # Returns:        nothing
  409. # Example:        
  410. #========================================================================
  411. # History:
  412. # ML    11/29/94    Added Exception Handling support
  413. # KTA    2/14/95    Added BooleanFlag to FindWindow() call
  414. #########################################################################
  415. task SetUpDocumentWindow(pWindowTitle,pTopScreenLocation := {0,20})
  416. begin
  417.     returnVal := 0;
  418.     try match [screen m:true r:?MainScreenRect];
  419.     catch theError
  420.         ExceptionDispatcher(theError);
  421.     
  422.     # Index of screen coordinates list
  423.     kLeft    := 1; kTop     := 2; kRight   := 3; kBottom  := 4;
  424.     
  425.     kDocWidth  := MainScreenRect[kRight] - 70;        # Calculate Doc W and H accordint to
  426.     kDocHeight := MainScreenRect[kBottom] - 50;        # the main screen size
  427.     
  428.     if (findWindow(pWindowTitle, true))
  429.     begin
  430.         DragWindow(pTopScreenLocation[1], pTopScreenLocation[2], 1, 1);                        # drag window to the top-left of the screen
  431.         SizeWindow(kDocWidth, kDocHeight, 1, 1);        # size window to constant coordinates
  432.         returnVal := 1;
  433.     end;  
  434.     
  435.     return(returnVal);
  436. end; # SetUpDocumentWindow();
  437.  
  438. #########################################################################
  439. #         PerformScroll( pEndPointRect, pWhichDirection := 1)
  440. #========================================================================
  441. # Author:        MDS
  442. # Description:    Uses Ivy to time how long it takes to scroll a document from
  443. #                top to bottom or viceversa
  444. # Parameters:    pDocumentName - name of the document in which to time scrolling
  445. #                pEndPointRect - list with the points of the rectangle containing
  446. #                                an image of the end point string
  447. #                pWhichDirection - in which direction to time scrolling:
  448. #                                    0 - Up, 1 - Down
  449. #                pWaitForScroll - Time to wait with scroll arrow held down Note:
  450. #                                this should be longer than the scroll should take
  451. #                                so IVY has time to locate the image.
  452. #                pScrollByLine - whether to scroll line by line or screen by screen
  453. #                                1 - line by line
  454. #                                0 - screen by screen
  455. #                pScrollCoords - 2 element list of coordinates of scroll point
  456. # Returns:        The actual time that takes to scroll    
  457. # Example:        
  458. # Assumptions:    1- The document contains a string which indicates the end point
  459. #                2- The string should be created with at least one space at the
  460. #                    begining and one space at the end, otherwise the cursur beam
  461. #                    will prevent Ivy from locating the end point string.
  462. #
  463. #========================================================================
  464. # History:
  465. # ML    5/27/94    add pDocumentName, pScrollByLine, pScrollCoords
  466. # ML    5/27/94    add option to scroll by line or screen
  467. #                defined different test cases
  468. # ML    6/28/94 return returnval
  469. # ML    11/29/94    Added Exception Handling support
  470. #########################################################################
  471. task PerformScroll( pDocumentName, pEndPointRect, pWhichDirection, pWaitForScroll, 
  472. pScrollByLine, pScrollCoords)
  473. begin
  474.     returnval := 0;    
  475.     if ( pWhichDirection = 0 )        # Scroll up
  476.         topOrBottom := 1;                               # where to scroll in the doc window (1 = Start at Bottom)
  477.     else    # Scroll down
  478.         topOrBottom := 0;                            # where to scroll in the doc window (0 = Start at top)
  479.     
  480.     # Position the Thumb at the top or Bottom of the document
  481.     if (global gScrollWindow)    # hook for Apps that don't scroll normally
  482.         Call( gScrollWindow, 'V', topOrBottom, 1 );
  483.     else
  484.         ScrollWindow('V', topOrBottom, 1 );
  485.     
  486.     if pWhichDirection # if scroll down
  487.     begin
  488.         if pScrollByLine # if scroll by line
  489.             logstr ("Moving pointer to the down arrow");
  490.         else # else scroll by screen
  491.             logstr ("Moving pointer to the scroll area above the down arrow");
  492.     end; # if pWhichDirection
  493.     else # else scroll up
  494.     begin
  495.         if pScrollByLine # if scroll by line
  496.             logstr ("Moving pointer to the up arrow");
  497.         else # else scroll by screen
  498.             logstr ("Moving pointer to the scroll area below the up arrow");
  499.     end; # scroll up
  500.     
  501.     scrollingPoint := { pScrollCoords[1], pScrollCoords[2] };
  502.     _move ('a', scrollingPoint);                    # Position mouse on top of Scrolling Arrow
  503.     # move a:scrollingArrow;                    # Position mouse on top of Scrolling Arrow    
  504.     
  505.     if pWhichDirection # if scroll down
  506.     begin
  507.         if pScrollByLine # if scroll by line
  508.         begin
  509.             global gTimedEvent := {9,"Scrolling down by line", "'{pDocumentName}'"};
  510.             logstr ("Scrolling down line by line");
  511.         end;
  512.         else # else scroll by screen
  513.         begin
  514.             global gTimedEvent := {10,"Scrolling down by screen", "'{pDocumentName}'"};
  515.             logstr ("Scrolling down screen by screen");
  516.         end;
  517.     end; # if pWhichDirection
  518.     else # else scroll up
  519.     begin
  520.         if pScrollByLine # if scroll by line
  521.         begin
  522.             global gTimedEvent := {11,"Scrolling up by line", "'{pDocumentName}'"};
  523.             logstr ("Scrolling up line by line");
  524.         end;
  525.         else # else scroll by screen
  526.         begin
  527.             global gTimedEvent := {12,"Scrolling up by screen", "'{pDocumentName}'"};
  528.             logstr ("Scrolling up screen by screen");
  529.         end;
  530.     end; # scroll up
  531.  
  532.     # define name of image file and search rect for ivy
  533.     global gImageFile := "Stop";
  534.     global gRect := pEndPointRect;
  535.     
  536.     StartTimerIV(); # start the timer
  537.     
  538.     _pressMouse();
  539.     Wait(pWaitForScroll);
  540.     _releasemouse();
  541.     
  542.     returnval := StopTimerIV(); # stop the timer
  543.     #println "returnval from PerformScroll is ",returnval;
  544.     return(returnval);
  545.     
  546. end; # PerformScroll( pEndPointRect, pWhichDirection := 1)
  547.  
  548. #########################################################################
  549. #         TimeScrolling( pDocumentName, pIterations, pWhichDirection )
  550. #========================================================================
  551. # Author:        MDS
  552. # Description:    Times the scrolling of a document
  553. # Parameters:    pDocumentName - name of the document in which to time scrolling
  554. #                pIterations -     how many iterations to time scrolling
  555. #                pWhichDirection - in which direction to time scrolling:
  556. #                                    0 - Up, 1 - Down
  557. #                pWaitForScroll - Time to wait with scroll arrow held down Note:
  558. #                                this should be longer than the scroll should take
  559. #                                so IVY has time to locate the image.
  560. #                pHowEndScroll - How IVY will know when the scroll is complete
  561. #                                {string} - scroll is complete when {string} appears
  562. #                                - must be formatted in 12 point Geneva!
  563. #                                1 - scroll is complete when thumbnail is at bottom of
  564. #                                scroll bar
  565. #                pScrollByLine - whether to scroll line by line or screen by screen
  566. #                                1 - line by line
  567. #                                0 - screen by screen
  568. # Returns:        The actual time that takes to scroll    
  569. # Example:        
  570. #========================================================================
  571. # History:
  572. # ML    3/31/94    Added IVInit and IVQuit, revised gTimedEvent
  573. # KTA    4/15/94    Added check to insure that IV initialized correctly
  574. # ML    5/27/94    add string, Thumbnail and scroll by screen option
  575. # ML    5/27/94    add pHowEndScroll, pScrollByLine
  576. # ML    5/27/94    calculate location of the scroll points based on location
  577. #                of thumbnail
  578. # ML    6/28/94 call PerformScroll() multiple times and increment pWaitForScroll
  579. #                if it isn't long enough
  580. # ML    11/29/94    Added Exception Handling support
  581. # ML    1/31/95    Use _Ivy calls
  582. #########################################################################
  583. TASK TimeScrolling( pDocumentName := "", pIterations := 1, pWhichDirection  := 1,
  584. pWaitForScroll := 35, pHowEndScroll := "Stop", pScrollByLine :=1)
  585. begin
  586.     global gScrollWindow;
  587.     if (SetUpDocumentWindow( pDocumentName ))
  588.     begin
  589.         if (InitIvy())
  590.         begin
  591.             # Scroll to set up for getting end point image
  592.             if (gScrollWindow)    # hook for Apps that don't scroll normally
  593.                 Call( gScrollWindow, 'V', pWhichDirection, 1 );    
  594.             else
  595.                 ScrollWindow('V', pWhichDirection, 1 );
  596.             
  597.             # get the position of the pointer - should be on thumbnail center
  598.             try match [mouse p:?ThumbCenter];
  599.             catch theError
  600.                 ExceptionDispatcher(theError);
  601.             
  602.             if typeof (pHowEndScroll) = 'string'    # if looking for string
  603.             begin
  604.                 try match[window o:1 r:?theRect];
  605.                 catch theError
  606.                     ExceptionDispatcher(theError);
  607.                 logstr ("Endpoint image is '{pHowEndScroll}' in 12 point Geneva");
  608.                 waitingRect := LocateTheString(theRect, pHowEndScroll);    # get it's location
  609.             end;
  610.             else # else calculate location of thumbnail
  611.             begin
  612.                 logstr ("Endpoint image is the Thumbnail");
  613.                 # println "ThumbCenter is ", ThumbCenter;
  614.                  ThumbNailLeftCoord := ThumbCenter[1] - 9;
  615.                 ThumbNailRightCoord := ThumbCenter[1] - 4;
  616.                 ThumbNailTopCoord := ThumbCenter[2] - 9;
  617.                 ThumbNailBottomCoord := ThumbCenter[2] + 9;
  618.                 waitingRect := {ThumbNailLeftCoord, ThumbNailTopCoord, ThumbNailRightCoord, 
  619.                 ThumbNailBottomCoord};
  620.             end;
  621.             
  622.             # println "waitingRect is ",waitingRect;
  623.             
  624.             _Ivy (task IVCreateImageFile, {"Stop", waitingRect});
  625.             
  626.             # calculate the location of the scroll points
  627.             if pScrollByLine
  628.             begin
  629.                 if pWhichDirection
  630.                     HScrollCoord := ThumbCenter[2] + 16;
  631.                 else
  632.                     HScrollCoord := ThumbCenter[2] - 16;
  633.             end; # if pScrollByLine
  634.             else # else scroll by screen
  635.             begin
  636.                 if pWhichDirection
  637.                     HScrollCoord := ThumbCenter[2] + 6;
  638.                 else
  639.                     HScrollCoord := ThumbCenter[2] - 6;
  640.             end; # scroll by screen
  641.             
  642.             ScrollCoords := { ThumbCenter[1], HScrollCoord };
  643.             
  644.             # println "ScrollCoords is ", ScrollCoords;
  645.             
  646.             for i := 1 to pIterations
  647.             begin
  648.                 tTime := 0;
  649.                 ScrollCounter := 1;
  650.                 while tTime = 0
  651.                 begin
  652.                     if ScrollCounter < 11
  653.                     begin
  654.                         waitTime := ScrollCounter * pWaitForScroll;
  655.                         #println "waitTime is ",waitTime;
  656.                         tTime := PerformScroll( pDocumentName, waitingRect, pWhichDirection, waitTime, pScrollByLine, ScrollCoords);
  657.                         ScrollCounter := ScrollCounter + 1;
  658.                     end; # if ScrollCounter < 11
  659.                     else
  660.                     begin
  661.                         tTime := -1; # bail out after 10 tries
  662.                         println "Unable to complete scroll with current pWaitForScroll parameters";
  663.                     end;
  664.                 end; # while tTime = 0
  665.             end; # for i := 1 to pIterations
  666.             
  667.             _Ivy (task IVDeleteImageFile, {"Stop"});
  668.             QuitIvy();
  669.         end; # if (IVInit(1))
  670.         else
  671.         begin
  672.             println "Problem initializing IV";
  673.             exit;
  674.         end;
  675.     end; # if (SetUpDocumentWindow( pDocumentName ))
  676.     
  677. end; # TimeScrolling( pDocumentName, pIterations )